package com.taobao.job;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: caoling
 * Date: 11-3-11
 * Time: 11:36
 * To change this template use File | Settings | File Templates.
 */
public class ItemInfoDO implements WritableComparable<ItemInfoDO> {
    double score;
    String itemInfo;

    public ItemInfoDO(double score, String itemInfo) {
        this.score = score;
        this.itemInfo = itemInfo;
    }

    private ItemInfoDO() {
    }

    public void write(DataOutput dataOutput)
            throws IOException {
        dataOutput.writeDouble(this.score);
        dataOutput.writeUTF(this.itemInfo);
    }

    public void readFields(DataInput dataInput) throws IOException {
        this.score = dataInput.readDouble();
        this.itemInfo = dataInput.readUTF();
    }

    public int compareTo(ItemInfoDO o) {
        if (this.score > o.score)
            return 1;
        if (this.score < o.score) {
            return -1;
        }
        return 0;
    }
}
